package com.findMoneyGame.pages.game.states {
	import flash.events.Event;

	import com.findMoneyGame.Engine;
	import com.findMoneyGame.models.User;
	import com.findMoneyGame.pages.shop.ImprovementsConfig;
	import com.findMoneyGame.pages.game.states.*;
	import com.findMoneyGame.pages.game.controllers.*;
	import com.findMoneyGame.pages.game.GameLevelPage;
	import com.findMoneyGame.pages.game.GameImage;

	public class PlayingState extends GameLevelPageState {
		
		private function get timeBonus () {
			var result : int;
			if (user.timeBonusIndex < 0) {
				result = ImprovementsConfig.noTimeBonus;
			} else {
				result = ImprovementsConfig.timeBonuses[user.timeBonusIndex];
			}
			return result;
		}

		public function PlayingState (gameLevelPage : GameLevelPage) { super(gameLevelPage); }

		public function start () {
			var gameTimer = new GameTimerController(gameLevelPage);
			new LoupeController(gameLevelPage);
			new HintController(gameLevelPage);
			new PassingController(gameLevelPage);
			new GameImageController(gameLevelPage);
			gameLevelPage.gameImage.addEventListener(
				GameImage.MONEY_FOUNDED,
				function (e : Event) {
					if (gameTimer.seconds <= timeBonus) {
						user.fastCompletedLevelCount++;
					}
				}
			);
			gameLevelPage.startGame();
		}
	}
}